package com.ignou.mca.evote;

import java.io.IOException;
import javax.servlet.Servlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.ignou.mca.beans.Message;
import com.ignou.mca.datasource.Encryption;

public class AdminLogin extends HttpServlet implements Servlet {
	public AdminLogin() {
		super();
	}

	protected void doGet(HttpServletRequest arg0, HttpServletResponse arg1)
			throws ServletException, IOException {
	}

	protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
		try {
			String UserName = req.getParameter("Username");
			String Password = req.getParameter("Password");
			Message message = new Message();
//			System.out.println("Username & Password :" + UserName + " "
//					+ Password);
//			Password = Encryption.encrypt(Password);
//			DatabaseConnection.Authenticate(UserName, Password, message);
//			HttpSession session = req.getSession();
//			session.setAttribute("Message", message);
//			ServletContext context = getServletContext();
//			if (!message.getMessage().equalsIgnoreCase("")) {
//				context.getRequestDispatcher("/AdminLogin.jsp").forward(req,
//						resp);
//			} else {
//				if (DatabaseConnection.Type.equalsIgnoreCase("2")) {
//					context.getRequestDispatcher("/AdminMenu.jsp").forward(req,
//							resp);
//				} else {
//					message
//							.setMessage("Invalid Username / Password. Please check and try again");
//					context.getRequestDispatcher("/AdminLogin.jsp").forward(
//							req, resp);
//				}
//			}
		}  catch (Exception e2) {
			e2.printStackTrace();
		}
	}
}